package com.fqh.service.impl;

import com.fqh.entity.Fooddetail;
import com.fqh.mapper.FoodDetailMapper;
import com.fqh.service.FoodDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FoodDetailServiceImpl implements FoodDetailService {

    @Autowired
    private FoodDetailMapper mapper;

    @Override
    public List<Fooddetail> findAllDetail(int page, int limit, String search) {
        search = search.trim();
        page = (page - 1) * limit;
        return mapper.findAllDetail(page, limit, search);
    }

    @Override
    public Integer findCount(String search) {
        search = search.trim();
        return mapper.findCount(search);
    }

    @Override
    public Integer addFoodDetail(Fooddetail fooddetail) throws Exception {
        return mapper.addFoodDetail(fooddetail);
    }

    @Override
    public void deleteByFoodClassid(Integer id) throws Exception {
        mapper.deleteByFoodClassid(id);
    }

    @Override
    public Fooddetail findFooddetailByFoodId(Integer id) {
        return mapper.findFooddetailByFoodId(id);
    }

    @Override
    public void updateFoodDetail(Fooddetail fooddetail) throws Exception {
        mapper.updateFoodDetail(fooddetail);
    }
}
